const KoaRouter = require('@koa/router')
const router = new KoaRouter()
const verify = require('../middleware/verifyToken')

const User = require('../controller/user')
const Goods = require('../controller/goods')
const Banner = require('../controller/banner')
const Cart = require('../controller/cart')
const version = '/api/v1'

router.get(`${version}/`, User.testApi)
router.post(`${version}/user/login`, User.login)

// 处理banner广告图
router.get(`${version}/banner/list`, Banner.list)
// 添加显示美食的列表
router.get(`${version}/goods/list`, Goods.list)
// 获取美食列表中的种类
router.get(`${version}/goods/cates`, Goods.cates)
// 获取美食的详情信息
router.get(`${version}/goods/detail`, verify, Goods.details)
// 添加美食的订单
router.post(`${version}/cart/add`, verify, Cart.addCart)
// 获取购物车的详情
router.get(`${version}/cart/list`, verify, Cart.list)
// 清空购物车
router.get(`${version}/cart/clear`, verify, Cart.clear)
// 删除单件的商品
router.get(`${version}/cart/sub`, verify, Cart.sub)
// 添加单件的商品数量
router.get(`${version}/cart/single`, verify, Cart.single)

module.exports = router